const router = require('koa-router')();
const model = require("../models/areacode");
const areacode = model();

router.prefix('/postgres')

/**
 * 测试连接
 */
router.get('/areacode', async (ctx, next) => {
    let resStr;
    try {
       const resData = await areacode.findAll();
        resStr = 'postgres Connection has been established successfully.';
        console.log(resData);
    } catch (error) {
        resStr = `Unable to connect to the database:${error}`;
        console.error(resStr);
    }
    ctx.body = `this is a hangao/list response:${resStr}`;
})

module.exports = router